C#

推荐列表 站点导航

当前位置:首页 > 脚本编程 > C# >

C#_C#将数字转换成字节数组的方法,本文实例讲述了C#将数字转换

来源:互联网  作者:网友投稿  发布时间:2021-01-07 08:19
C#将数字转换成字节数组的方法,本文实例讲述了C#将数字转换成字节数组的方法。分享给大家供大家参考。具体实现方...

下面的代码用到了MemoryStream 和 BinaryWriter

// Create a byte array from a decimal public static byte[] DecimalToByteArray (decimal src) { // Create a MemoryStream as a buffer to hold the binary data using (MemoryStream stream = new MemoryStream()) { // Create a BinaryWriter to write binary data to the stream using (BinaryWriter writer = new BinaryWriter(stream)) { // Write the decimal to the BinaryWriter/MemoryStream writer.Write(src); // Return the byte representation of the decimal return stream.ToArray(); } } }

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jiaob/c/11738.shtml

最新文章
热门文章
Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

C#_C#将数字转换成字节数组的方法,本文实例讲述了C#将数字转换

2021-01-07 编辑:网友投稿

下面的代码用到了MemoryStream 和 BinaryWriter

// Create a byte array from a decimal public static byte[] DecimalToByteArray (decimal src) { // Create a MemoryStream as a buffer to hold the binary data using (MemoryStream stream = new MemoryStream()) { // Create a BinaryWriter to write binary data to the stream using (BinaryWriter writer = new BinaryWriter(stream)) { // Write the decimal to the BinaryWriter/MemoryStream writer.Write(src); // Return the byte representation of the decimal return stream.ToArray(); } } }

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jiaob/c/11738.shtml

相关文章

风云图片

推荐阅读

返回C#频道首页